<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>
    function prime(n) {
        if (n == 2) return true;

        if (n <= 1 || n % 2 === 0)
            return false;

        for (var c = 3; c * c <= n; c += 2)
            if (n % c === 0)
                return false;
        return true;
    }

    function sumPrimes(num) {
        var sum = num >= 2 ? 2 : 0;
        for (var n = 3; n <= num; n += 2)
            if (prime(n))
                sum += n;
        return sum;
    }

    sumPrimes(10);
</script>
</body>
</html>